package com.dubito.dose.feature.addmedication.navigation

import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import com.dubito.dose.core.navigation.DoseNavigationDestination
import com.dubito.dose.domain.model.Medication
import com.dubito.dose.feature.addmedication.AddMedicationRoute

/**
 * author: LiLiang
 * createTime: 2022/9/4-0:51
 * remark:
 **/
object AddMedicationDestination : DoseNavigationDestination {

    override val route: String
        get() = "add_medication"
    override val destination: String
        get() = "add_medication_destination"
}

fun NavGraphBuilder.addMedicationGraph(
    bottomVisibility: MutableState<Boolean>,
    fabVisibility: MutableState<Boolean>,
    onBackClicked: () -> Unit,
    navigateToMedicationConfirm: (Medication) -> Unit
) {
    composable(AddMedicationDestination.route) {
        LaunchedEffect(null) {
            bottomVisibility.value = false
            fabVisibility.value = false
        }
        AddMedicationRoute(
            onBackClicked = onBackClicked,
            navigateToMedicationConfirm = navigateToMedicationConfirm
        )
    }
}